var e = require("../../../../@babel/runtime/helpers/interopRequireDefault").default,
  t = require("../../../../@babel/runtime/helpers/objectSpread2"),
  r = require("../../../../@babel/runtime/helpers/regeneratorRuntime"),
  a = require("../../../../@babel/runtime/helpers/asyncToGenerator"),
  n = require("../../../../utils/index"),
  i = e(require("./behavior")),
  s = n.tools.common.getHeaderHeight;

function o() {
  return c.apply(this, arguments)
}

function c() {
  return (c = a(r().mark((function e() {
    var t, a, n, i;
    return r().wrap((function (e) {
      for (;;) switch (e.prev = e.next) {
        case 0:
          t = this.getStorageKey(), a = this.getFilterParamsInfo(t), n = a.sort, i = a.type, this.setData({
            typePick: i || {},
            sortPick: n || {}
          });
        case 2:
        case "end":
          return e.stop()
      }
    }), e, this)
  })))).apply(this, arguments)
}
Component({
  useStore: function (e) {
    return {
      sortClass: e.global.sortClass
    }
  },
  behaviors: [i.default],
  properties: {
    active: {
      value: null
    }
  },
  data: {
    sortPickerTop: "calc(170rpx + 100rpx + ".concat(s("14rpx")),
    typePick: "",
    sortPick: "",
    showTypePicker: !1,
    showSortPicker: !1,
    tabList:[{
      title: "求租",
      mode: t.seeking,
      "filter-key": "seekingParams"
    }, {
      title: "出租",
      mode: t.hire,
      "filter-key": "hireParams"
    }, {
      title: "驾驶员招聘",
      mode: t.recruit,
      "filter-key": "driverRecruitParams"
    }
    ]
  },
  methods: {
    onTabChange: function (e) {
      var t = this;
      return a(r().mark((function a() {
        var n;
        return r().wrap((function (r) {
          for (;;) switch (r.prev = r.next) {
            case 0:
              if (r.t0 = e.detail, !r.t0) {
                r.next = 7;
                break
              }
              return r.next = 4, t.setFilterParamsInfo("tabValue", null === (n = e.detail) || void 0 === n ? void 0 : n.index);
            case 4:
              t.refresh(), o.call(t), t.onSwitchSortPicker(!1);
            case 7:
            case "end":
              return r.stop()
          }
        }), a)
      })))()
    },
    onOpenPicker: function (e) {
      var t = this;
      return a(r().mark((function a() {
        var n, i, s, o, c, u;
        return r().wrap((function (r) {
          for (;;) switch (r.prev = r.next) {
            case 0:
              if (i = e.target.dataset, s = i.type, o = i.tabActive, !s || "sort" !== s) {
                r.next = 3;
                break
              }
              return r.abrupt("return", void t.onSwitchSortPicker(!0));
            case 3:
              if (t.onSwitchSortPicker(!1), 2 !== o) {
                r.next = 5;
                break
              }
              return r.abrupt("return", void t.onSwitchTypePicker());
            case 5:
              c = t.getStorageKey(), u = t.getFilterParamsInfo(c), $.router.push("/subpackage/common/multi-role-select/index", {
                type: "machinery",
                isUpdateStorage: 0,
                selectValue: JSON.stringify((null == u || null === (n = u.type) || void 0 === n ? void 0 : n.value) || [])
              });
            case 7:
            case "end":
              return r.stop()
          }
        }), a)
      })))()
    },
    onSwitchSortPicker: function (e) {
      "boolean" != typeof e ? this.setData({
        showSortPicker: !this.data.showSortPicker
      }) : this.setData({
        showSortPicker: e
      })
    },
    onSortFilterChange: function (e) {
      var n = this;
      return a(r().mark((function a() {
        var i, s;
        return r().wrap((function (r) {
          for (;;) switch (r.prev = r.next) {
            case 0:
              return i = n.getStorageKey(), s = n.getFilterParamsInfo(i), r.next = 3, n.setFilterParamsInfo(i, t(t({}, s), {}, {
                sort: e.detail || ""
              }));
            case 3:
              n.refresh(), o.call(n);
            case 5:
            case "end":
              return r.stop()
          }
        }), a)
      })))()
    },
    onSwitchTypePicker: function () {
      this.setData({
        showTypePicker: !this.data.showTypePicker
      })
    },
    onTypeFilterChange: function (e) {
      var n = this;
      return a(r().mark((function a() {
        var i, s;
        return r().wrap((function (r) {
          for (;;) switch (r.prev = r.next) {
            case 0:
              return i = n.getStorageKey(), s = n.getFilterParamsInfo(i), r.next = 3, n.setFilterParamsInfo(i, t(t({}, s), {}, {
                type: e.detail || ""
              }));
            case 3:
              n.refresh(), o.call(n);
            case 5:
            case "end":
              return r.stop()
          }
        }), a)
      })))()
    },
    onClearSelectLabel: function (e) {
      var t = this;
      return a(r().mark((function a() {
        var n;
        return r().wrap((function (r) {
          for (;;) switch (r.prev = r.next) {
            case 0:
              return n = e.target.dataset.type, r.next = 3, t.clearTabFilterStorage(n);
            case 3:
              t.refresh(), o.call(t);
            case 5:
            case "end":
              return r.stop()
          }
        }), a)
      })))()
    },
    refresh: function () {
      var e = this;
      return a(r().mark((function t() {
        var a, n, i;
        return r().wrap((function (t) {
          for (;;) switch (t.prev = t.next) {
            case 0:
              a = e.getStorageKey(), n = e.getFilterParamsInfo(a), i = e.getTabMode(), n.mode = i, e.triggerEvent("refresh", {
                item: n
              });
            case 2:
            case "end":
              return t.stop()
          }
        }), t)
      })))()
    }
  },
  ready: function () {
    this.setData({
      tabFilterParams: t(t({}, this.data.tabFilterParams), {}, {
        tabValue: this.data.active
      })
    })
  },
  pageLifetimes: {
    show: function () {
      var e = this;
      return a(r().mark((function a() {
        var i, s, c;
        return r().wrap((function (r) {
          for (;;) switch (r.prev = r.next) {
            case 0:
              if (null == (i = $.router.getParams()) || !i.label || null == i || !i.value) {
                r.next = 7;
                break
              }
              return s = e.getStorageKey(), c = e.getFilterParamsInfo(s), r.next = 5, e.setFilterParamsInfo(s, t(t({}, c), {}, {
                type: {
                  value: i.value,
                  label: i.label
                }
              }));
            case 5:
              return r.next = 7, e.refresh();
            case 7:
              n.operateDom.nextTick((function () {
                o.call(e)
              }));
            case 8:
            case "end":
              return r.stop()
          }
        }), a)
      })))()
    }
  }
});